#pragma once

#include <string>
#include <set>
#include <windows.h>
#include <iostream>

#include "boost/filesystem/operations.hpp"
#include "boost/algorithm/string.hpp"

#include "IndexMap.h"


struct searchParameters
{
	int minWordLength;
	int maxWordLength;
};


class ISearcheableFile
{

protected:

	bool checkInWord(std::string& word, std::set<std::string>& wordSet, std::set<std::string>& foundWords);

	HANDLE openFile(std::string& fileName);
	DWORD readInBuffer(HANDLE file, char* buffer);

public:

	static const long TEN_MB = 10 * 1024 * 1024;
	static const int  BUFFER_SIZE =  512 * 1024;

	static const char WORD_SEPARATOR = ' ';
	static const char LEFT_TAG = '<';
	static const char RIGHT_TAG = '>';

	static char* buffer;

	static bool isApplicableForSearch(std::string& path);

	void searchForIndexing(struct searchParameters params, std::set<int>* indexes, IndexMap* indexMap);

	virtual std::set<std::string>* search(std::set<std::string>& wordSet, struct searchParameters params) = 0;	

};
